/* 运行时配置 */
import { history } from "umi";
import "./global.less";

/* 路由变化时 */
const defaultTitle = "";
export function onRouteChange({ routes, matchedRoutes, location, action }) {
  if (matchedRoutes.length) {
    document.title =
      matchedRoutes[matchedRoutes.length - 1].route.title || defaultTitle;
  }
}

export function patchRoutes({ routes }) {
  // 在这里做接口查询权限
  // ...
}

/* 渲染之前权限校验 */
export function render(oldRender) {
  // fetch('/api/auth').then(auth => {
  //   if (auth?.isLogin) { oldRender() }
  //   else {
  //     history.push('/login')
  //     oldRender()
  //   }
  // })
  // console.warn(1000)
  // history.push('/app/portal')
  oldRender();
}
